<!DOCTYPE html>
<html>
<body>
<p>This test ensures that a synthetic event dispatched on a plugin doesn't cause a crash.</p>
<embed id="plugin" type="application/x-webkit-test-webplugin"></embed>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}
var plugin = document.getElementById("plugin");

var listenerCalledCount = 0;
var eventTypes = ["touchmove", "gesturescrollstart", "mousewheel"];

eventTypes.forEach(function(eventType) {
    plugin.addEventListener(eventType, function(event) {
        listenerCalledCount++;
        if (listenerCalledCount == eventTypes.length) {
            if (window.testRunner) {
                testRunner.notifyDone();
            }
        }
    });
});

var event = document.createEvent("PopStateEvent");
event.initEvent("touchmove", true, true);
plugin.dispatchEvent(event);

event = document.createEvent("PopStateEvent");
event.initEvent("gesturescrollstart", true, true);
plugin.dispatchEvent(event);

event = document.createEvent("PopStateEvent");
event.initEvent("mousewheel", true, true);
plugin.dispatchEvent(event);
</script>
</body>
</html>
